package com.enqualcomm.kids.activities;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;

import com.enqualcomm.kids.R;
import com.enqualcomm.kids.base.BaseActivity;

import java.util.Locale;

public class AgreementActivity extends BaseActivity implements View.OnClickListener {

    WebView agreement_webview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_agreement);

        initView();
        initData();
    }

    private void initView() {
        findViewById(R.id.title_bar_left_iv).setOnClickListener(this);
        TextView title_bar_name = (TextView) findViewById(R.id.title_bar_title_tv);
        title_bar_name.setText(getString(R.string.about_install_permission));
        TextView title_bar_terminal_name_tv = (TextView) findViewById(R.id.title_bar_terminal_name_tv);
        View title_bar_terminal_icon_iv = findViewById(R.id.title_bar_terminal_icon_iv);
        title_bar_terminal_icon_iv.setVisibility(View.GONE);
        title_bar_terminal_name_tv.setVisibility(View.VISIBLE);
        title_bar_terminal_name_tv.setText(getString(R.string.about_install_permission));

        agreement_webview = (WebView) findViewById(R.id.agreement_webview);
    }

    private void initData() {
//        if ("畅宇国际-熊卫士守护者".equals(BuildConfig.CHANNEL)) {
        if (Locale.SIMPLIFIED_CHINESE.equals(getResources().getConfiguration().locale)) {
            agreement_webview.loadUrl("file:///android_asset/agreement.html");
        } else if ("zh".equals(getResources().getConfiguration().locale.getLanguage())) {
            agreement_webview.loadUrl("file:///android_asset/agreement_tradition.html");
        } else {
            agreement_webview.loadUrl("file:///android_asset/agreement_english.html");
        }
//        if ("CN".equals(Locale.getDefault().getCountry().toUpperCase(Locale.getDefault()))) {
//            agreement_webview.loadUrl("file:///android_asset/agreement.html");
//        } else if ("TM".equals(Locale.getDefault().getCountry().toUpperCase(Locale.getDefault()))||"HK".equals(Locale.getDefault().getCountry().toUpperCase(Locale.getDefault()))||"CO".equals(Locale.getDefault().getCountry().toUpperCase(Locale.getDefault()))) {
//            agreement_webview.loadUrl("file:///android_asset/agreement_tradition.html");
//        } else {
//            agreement_webview.loadUrl("file:///android_asset/agreement_english.html");
//        }
//        } else {
//            if (Locale.SIMPLIFIED_CHINESE.equals(getResources().getConfiguration().locale)) {
//                agreement_webview.loadUrl("file:///android_asset/agreement.html");
//            } else {
//                agreement_webview.loadUrl("file:///android_asset/agreement_english.html");
//            }
//        }
//


    }

    @Override
    public void onClick(View v) {
        finish();
    }
}
